package com.lovo.middleman.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lovo.middleman.bean.StockBean;
import com.lovo.middleman.bean.StockPageBean;
import com.lovo.middleman.service.IStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/stock")
public class StockController {

    @Autowired
    IStockService iStockService;

    @RequestMapping("/getAllStock")
    public List<StockBean> getAllStock(){
        return iStockService.queryStockBean();
    }

    @RequestMapping("/addStockBean")
    public void addStockBean(@RequestBody StockBean stockBean){
        iStockService.addStockBean(stockBean);
    }

    @RequestMapping("/getStockBeanById")
    public StockBean getStockBeanById(int stockId){
     return    iStockService.queryStockBeanById(stockId);
    }

    @RequestMapping("/stockBeanPage")
    public Page<StockBean> stockBeanPage(int curPage,
                                         int pageSize,
                                         String goodsName,
                                         String goodsType){
       return iStockService.queryStockBeanByItem(curPage,pageSize,goodsName,goodsType);
    }

    @RequestMapping("/getStockPage")
    public Page<StockBean> getStockPage(@RequestBody StockPageBean<StockBean> stockPageBean){
        return iStockService.queryStockPageBean(stockPageBean);
    }

    @RequestMapping("/updateStockBeanPriceById")
    public void updateStockBeanPriceById(int id, double marketingPrice){
        iStockService.updateStockPriceById(id,marketingPrice);
    }
}
